﻿using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.StaticFiles;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using W.Warehouse.Api.Application.Command.BinLocationCommand;
using W.Warehouse.Domain;
using W.Warehouse.Domain.DTO;
using W.Warehouse.Read.Api.Application.Command.BinLocationCommands;
using W.Warehouse.Read.Api.Application.Command.WarehouseCommands;

namespace W.Warehouse.Read.Api.Controllers
{
    /// <summary>
    /// 库位管理列表
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize]
    public class BinLocationMangeController : ControllerBase
    {
        private readonly IMediator _mediator;
        public BinLocationMangeController(IMediator mediator)
        {
            _mediator = mediator;
        }
        /// <summary>
        /// 显示库位类型
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<List<WarehouseLocation>>> GetWarehouseLocation()
        {
            return await _mediator.Send(new WarehouseLocationSelectCommand());
        }
        /// <summary>
        /// 显示库位类型
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<List<WarehouseDTO>>> GetWarehouseList()
        {
            return await _mediator.Send(new BinLocationGetWarehouseListCommand());
        }
        /// <summary>
        /// 显示查询分页库位列表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<BinLocationPageDTO>> GetBinLocation([FromQuery]BinLocationSelectCommand command)
        {
            return await _mediator.Send(command);
        }
        /// <summary>
        /// 反填库位管理
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<BinLocation>> FanBinLocation([FromQuery] BinLocationFanCommand command)
        {
            return await _mediator.Send(command);
        }
        /// <summary>
        /// 显示库位下拉
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<List<WBDTO>>> GetBinLocationName()
        {
            return await _mediator.Send(new BinLocationSelectNameCommand());
        }
    }
}
